package ytdp.careagle.com.ytdp.mvp.presenter;

import android.app.Activity;
import android.content.Context;

import java.util.HashMap;
import java.util.List;

import ytdp.careagle.com.ytdp.app.G;
import ytdp.careagle.com.ytdp.mvp.mode.FinancialProgramModel;
import ytdp.careagle.com.ytdp.mvp.view.IFinancialProgramView;
import ytdp.careagle.com.ytdp.net.MyObserver;
import ytdp.careagle.com.ytdp.net.NetWorks;
import ytdp.careagle.com.ytdp.net.Result;
import ytdp.careagle.com.ytdp.net.Results;

/**
 * Created by admin on 2017/10/11.
 */

public class FinancialProgramPresenter {
    private IFinancialProgramView view;
    private FinancialProgramModel model;

    public FinancialProgramPresenter(IFinancialProgramView view) {
        this.view = view;
        this.model = new FinancialProgramModel();
    }

    public void getVehicleModelParams(Context context) {
        String codes = view.modeCodes();
        boolean all = view.isALl();
        model.getVehicleModelParams(context, G.getHeader(context), codes, all, new MyObserver<Results<List<String>>>() {
            @Override
            public void onNext(Results<List<String>> result) {
                super.onNext(result);
                if (result.getCode() == G.REQUEST_OK) {
                    view.setCarConfig(result.getData());
                } else {
                    view.showMessage(result.getMessage());
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                view.showMessage("获取车型配置失败");
            }
        });

    }
}
